package cn.gov.msa.controller;

import javax.servlet.http.HttpSession;

import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import cn.gov.msa.util.PropertiesTools;
import cn.gov.msa.util.WebServiceTools;
import cn.msa.gov.model.UserDetail;
import net.sf.json.JSONObject;

/**   
* @Title: BusinessControll.java 
* @Package cn.gov.msa.controller 
* @Description: TODO(用一句话描述该文件做什么) 
* @author 何宇江  
* @date 2018年2月21日 上午11:34:09 
*/

@RestController
@RequestMapping(value = "/consulting", produces = "text/plain;charset=UTF-8")
public class ConsultingController {

	private String methods = "stirnggetData";
	private static String url  = PropertiesTools.readProperties("gahWS.url");
	@RequestMapping(value = "/list", method = RequestMethod.POST)
	public String getList(@RequestBody JSONObject param, HttpSession session) throws Exception {

		UserDetail userDetail = (UserDetail)session.getAttribute("user");
		String userId = userDetail.getUserId();
		param.put("userId", userId);
        String[] parameter = new String[]{"DKU301", param.toString()};       
        String result = WebServiceTools.getDatasByUrl(url, methods, parameter);
           	
        return result;  
    } 
	
	@RequestMapping(value = "/addConsulting", method = RequestMethod.POST)
	public String addViewCount(@RequestBody JSONObject param, HttpSession session) throws Exception {

		UserDetail userDetail = (UserDetail)session.getAttribute("user");
		String userId = userDetail.getUserId();
		param.put("userId", userId);
		String[] parameter = new String[]{"DKU301_1", param.toString()};       
        String result = WebServiceTools.getDatasByUrl(url, methods, parameter);
           	
        return result;  
    }

}
